import java.util.Scanner;

public class Test1 {
    public static int func(String str1, String str2){
        String result = "";
        for (int i = 1; i < str1.length(); i++) {
            StringBuilder stringBuilder = new StringBuilder();
            for (int j = i-1; j < str1.length(); j++) {
                if(str2.contains(stringBuilder.append(str1.charAt(j)))){
                    if(result.length() <= stringBuilder.length()){
                        result = stringBuilder.toString();
                    }
                }
            }
        }
        return result.length();
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        if(str1.length() < str2.length()){
            func(str1,str2);
        }else{
            func(str2,str1);
        }
        System.out.println(func(str1,str2));
    }
}
